<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.*" %>
<% request.setCharacterEncoding("utf-8");%>
<% String id=request.getParameter("stuId");%>
<% String stuName=request.getParameter("stuName");%>
<% String stuBirthday=request.getParameter("stuBirthday");%>
<% String stuClass=request.getParameter("stuClass");%>
<html>
<head>
    <title>条件查询</title>
    <%
        String dbName = "jdbc";
        String userName = "root";
        String userPasswd = "123456";
        String url = "jdbc:mysql://localhost/"+"?user="+userName+"&password="+userPasswd;
        Class.forName("com.mysql.jdbc.Driver");
        Connection conn= DriverManager.getConnection(url);
        Statement statement =conn.createStatement();
        String sql = "INSERT into student VALUES('"+id+"','"+stuName+"','"+stuBirthday+"','"+stuClass+"')";
        int result=statement.executeUpdatr(sql);
        if (result>0)
            out.print("<script type='text/javascript'>alert('添加成功');</script>");
        else
            out.print("<script type='text/javascript'>alert('添加失败');</script>");
        sql = "select*from student";
        rs = statement.executeQuery(sql);
    %>
</head>
<body>
<table border="1">
    <th colspan="4"style="font-size: x-large;alignment: center">学生信息</th>
    <tr style="text-align: center">
        <th>学号</th>
        <th>姓名</th>
        <th>出生日期</th>
        <th>所在班级</th>
    </tr>
        <%
        while (rs.next()){
    %>
    <tr style="text-align: center;">
        <td><%=rs.getString(1)%></td>
        <td><%=rs.getString(2)%></td>
        <td><%=rs.getString(3)%></td>
        <td><%=rs.getString(4)%></td>
    </tr>
        <%}%>
        <%
        rs.close();
        statement.close();
        conn.close();
    %>
</body>
</html>